/**
 * 
 */
package edu.byu.nlp.pipes;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.google.common.base.Function;

/**
 * Strips the header from an RFC-822 style message.
 * 
 * @author robbie
 *
 */
public class HeaderStripper implements Function<String, String>, Serializable {
	
	private static final long serialVersionUID = 1L;

	private static final Pattern BLANK_LINE_PATTERN = Pattern.compile("\n\n|\r\r|\n\r\n\r");
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String apply(String input) {
		Matcher matcher = BLANK_LINE_PATTERN.matcher(input);
		if (!matcher.find()) {
			return "";
		}
		return input.substring(matcher.end(), input.length());
	}

}
